﻿
using GalFrameWork.Models;
using System.Data;

namespace GalFrameWork.Utils;

public class DatatableUtil {
    public static List<T> DatatableToEntity<T>(DataTable dt)
    {
        return null;
    }

    public static List<MyDialog> ReadDatatabelToMyDialogs(DataTable tabel)
    {
        var list = new List<MyDialog>();
        var dt = tabel;
        foreach (DataRow row in dt.Rows)
        {
            var dialog = new MyDialog
            {
                Id = int.Parse(row["Id"].ToString()),
                SceneId = int.Parse(row["SceneId"].ToString()),
                SpeakerName = row["SpeakerName"].ToString(),
                Sentence = row["Sentence"].ToString()
            };
            list.Add(dialog);
        }
        return list;
    }
}

